package com.waiting.innerClass;

/**
 * @Description 内部类学习
 * @Author bjweitingting
 * @Date 2018/12/29
 **/
public class OuterClass {

    public String param="外部类的public字段";

    private String param_two="外部类的private字段";

    public static class StaticInnerClass{
        public int age;
        private String name;

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }
        public static void test(){
            System.out.println("调用静态内部类");
        }
    }

    public class InnerClass{
        public String param="这是普通内部类的成员变量";
        public void test(){
            //普通内部类，可以访问外部类的成员
            System.out.println(param); //这里发生了覆盖，访问的是本类的parm成员
            System.out.println("OuterClass.this.param:"+OuterClass.this.param);
            System.out.println(param_two);
        }
    }
    //匿名内部类
    public void test(){
        String test_param="匿名内部类输出";
        int test_int=100;
        new Thread(){
            @Override
            public void run() {
                System.out.println(test_param);
                System.out.println(test_int);
            }
        }.start();
    }
}
